package leetcode;

class Solution_45 {
    public int jump(int[] nums) {
        if (nums.length == 1) return 0;
        int minStep = 0;
        int nextJump = 0;
        int curJump = 0;
        for (int i = 0; i < nums.length; i++) {
            nextJump = Math.max(nums[i] + i,nextJump);

            if ( curJump == i){
                curJump = nextJump;
                minStep ++;
                if (nextJump >= nums.length -1) break;
            }
        }
        return minStep;
    }
}